package com.itheima.leetcode.od.c.string;

import java.util.Arrays;
import java.util.Scanner;

/**
 * <h3>输出指定字母在字符串的中的索引</h3>
 */
public class IndexOfSpecifiedLetter {
    // 输入获取
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String str = sc.next();
        int idx = sc.nextInt();

        System.out.println(getResult(str, idx));
    }

    // 算法入口
    public static int getResult(String str, int idx) {
        char[] sArr = str.toCharArray();
        Arrays.sort(sArr);
        char target = sArr[idx - 1];
        return str.indexOf(target);
    }
}